#ifndef CANVASTOOLBARMODEL_H
#define CANVASTOOLBARMODEL_H

#include <QAbstractListModel>
#include <QList>

/*!
 * @ClassName : CanvasToolType
 * @Brief     : 自定义枚举类型
 * @Author    : BinWatson
 * @Data      : 2022-06-07 12:14:24
 * @Details   : 用于区别Canvas画布旁边工具栏里面的选项类型
 */
class CanvasToolType : public QObject
{
    Q_OBJECT
public:
    enum Type {
        Cancel,     // 取消
        Rectangle,  // 矩形
        Circle,     // 圆形
        Backout,    // 撤销
        Clear,      // 清空
        Save,       // 保存
        Load,       // 加载
        length      // 总长度
    };

     Q_ENUM(Type)
};

using ToolType = CanvasToolType::Type;
Q_DECLARE_METATYPE(ToolType)

struct CanvasTool
{
    QString  m_name;
    ToolType m_type;
    QString  m_message;
    QString  m_norImg;
    QString  m_actImg;
};

using Tool = CanvasTool;

class CanvasToolBarModel : public QAbstractListModel
{
    Q_OBJECT
public:
    enum RoleName {
        ToolType = Qt::DisplayRole, // 工具类型
        ToolName,                   // 工具名字
        ToolMessage,                // 工具显示信息
        ToolNorImg,                 // 正常情况下的图片
        ToolActImg,                 // 激活情况下的图片
    };

    static CanvasToolBarModel* instance();

    explicit CanvasToolBarModel(QObject *parent = nullptr);

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    virtual QHash<int,QByteArray> roleNames() const override;

private:
    QList<Tool> m_tools;
};

#endif // CANVASTOOLBARMODEL_H
